Skip to content

feat(cli): run app dev candidates through execa#117

Open
AmanVarshney01 wants to merge 2 commits into
mainfrom
feat/cli-execa-local-dev
Open

feat(cli): run app dev candidates through execa#117
AmanVarshney01 wants to merge 2 commits into
mainfrom
feat/cli-execa-local-dev

Conversation

@AmanVarshney01

Copy link
Copy Markdown
Member

Companion to project-compute#106 (approved): the SDK's spawn layer moved to execa there; this migrates the one remaining Windows-broken spawn site in the CLI, the app dev launcher ladder in lib/app/local-dev.ts.

Why

The ladder spawned candidates with raw spawn and no shell. On Windows, npx is a .cmd shim, which raw spawn cannot launch (only .exe/.com resolve), so the npx rung always failed with a false ENOENT and Next.js dev degraded to bunx-or-bust. There was even a hand-rolled next.cmd special case for the local-bin rung; execa (via cross-spawn, PATHEXT) makes that unnecessary, so it's gone.

execa is already a CLI dependency (controllers/init.ts, controllers/agent.ts), so no new ecosystem choice.

Survey of remaining spawn sites (checked all of packages/)

  • lib/app/local-dev.ts: migrated here.
  • shell/update-check.ts: spawns process.execPath (an absolute path to the running Node binary) detached and unref'd. No PATH or shim resolution involved, no output handling, and execa adds nothing but risk around unref semantics. Left as is, deliberately.
  • adapters/git.ts, lib/git/local-status.ts: execFile("git", ...); git.exe resolves fine on Windows. Left as is.

Behavior preserved

  • Inherited stdio (the dev server streams straight to the terminal).
  • ENOENT falls through to the next candidate; ladder exhaustion still throws the friendly install message.
  • Exit code and termination signal are reported, and abort still surfaces as SIGTERM so the controller's cancel mapping (AbortError) is unchanged.
  • Child env passed exactly (extendEnv: false).
  • One deliberate improvement: a non-ENOENT spawn failure (e.g. EACCES) now surfaces with execa's readable message instead of a raw errno throw.
  • Dropped the unused spawnImpl injection seam; nothing consumed it (tests mock runLocalApp itself).

Testing

  • Full suite: 45 files / 624 tests pass; typecheck and build clean.
  • Live smoke of the migrated path: a real bun --watch app spawns, streams output, and terminates cleanly on abort (SIGTERM reported); an all-ENOENT ladder (empty PATH) produces the friendly message.

Migrates the local dev-server launcher ladder from raw
node:child_process spawn to execa (already a CLI dependency). execa
spawns through cross-spawn, so on Windows the npx rung resolves its
.cmd shim via PATHEXT instead of always failing with a false ENOENT,
which made the Next.js ladder bunx-or-bust there. The hand-rolled
win32 next.cmd special case goes away for the same reason.

Behavior preserved: inherited stdio, ENOENT falls through to the next
candidate, exit code and termination signal are reported (SIGTERM on
abort still maps to the controller's cancel path), and the child env
is passed exactly (extendEnv: false). Spawn failures other than ENOENT
now surface with execa's message instead of a raw errno throw. Drops
the unused spawnImpl injection seam; tests mock runLocalApp itself.

Verified live: bun --watch runs and terminates cleanly on abort, and
an all-ENOENT ladder still produces the friendly install message.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5d689511-3e81-4128-9c00-99c2955573e1

📥 Commits

Reviewing files that changed from the base of the PR and between f502045 and 0d2e4a5.

📒 Files selected for processing (1)
  • packages/cli/src/lib/app/local-dev.ts

Summary by CodeRabbit

  • Bug Fixes
    • Improved local development command execution by standardizing launch behavior across Next.js and Bun.
    • Enhanced the fallback sequence: commands that aren’t found now reliably proceed to the next candidate.
    • Cancellation handling is now more consistent when starting local apps.
    • Non-missing start failures (such as permission or setup issues) now surface clearer, more actionable errors.

Walkthrough

Local development command execution was standardized on execa. The launcher no longer accepts an injectable spawn implementation, and Next.js and Bun use the internal fallback runner. The runner inherits stdio, disables environment extension, supports cancellation, continues to alternate candidates when binaries are missing, throws for other failed starts, and normalizes exit results.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: switching app dev candidates to execa.
Description check ✅ Passed The description directly describes the local-dev execa migration and its rationale.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-execa-local-dev
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/cli-execa-local-dev

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant